//****************************************************************
//* Copyright (c) 2004 Ford Motor Company. All Rights Reserved.
//*
//* $$Workfile:   WSLSecurityDao.java  $$
//* $$Revision:   1.2  $$
//* $$Author:   aponte  $$
//* $$Date:   Dec 15 2008 07:08:28  $$
//*
//*****************************************************************
package ar.com.ford.it.fullEconomics.persistence.dao;

import java.util.Collection;
import ar.com.ford.it.fullEconomics.persistence.dto.Tms0005AccprofVw;
import ar.com.ford.it.fullEconomics.persistence.dto.Tms0008UsrprofVw;
import ar.com.ford.it.webengine.persistence.PersistenceUtil;
import com.ford.it.logging.ILogger;
import com.ford.it.logging.Level;
import com.ford.it.logging.LogFactory;
import com.ford.it.persistence.PersistenceException;
import com.ford.it.persistence.PersistenceManager;
import com.ford.it.persistence.Query;

/**
 * 
 * @author aponte
 */
public class WSLSecurityDao extends Dao {

	private static final String CLASS_NAME = WSLSecurityDao.class.getName();

	private static final ILogger log = LogFactory.getInstance().getLogger(
			CLASS_NAME);

	/**
	 * Returns a collection of permissions for an especific: SystemCode
	 * PlantCode ProfileCode
	 * 
	 * @param tms0005AccprofVw
	 * @return Tms0005AccprofVw Collection
	 */
	public Collection findPermissonsByUsr(Tms0005AccprofVw tms0005AccprofVw) {

		String METHOD_NAME = "findPermissonsByUsr";

		Collection resultCol = null;
		PersistenceManager pm = null;

		try {
			pm = PersistenceUtil.getPersistenceManager();
			Query query = pm.newQuery("findPermissonsByUsrQuery",
					Tms0005AccprofVw.class);
			query.setParameters(tms0005AccprofVw);
			resultCol = (Collection) pm.executeQuery(query);
		} catch (PersistenceException e) {
			log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME,
					"ERROR buscando permisos por usuario.", e);
		}
		return resultCol;
	}

	public Collection findUsr(Tms0008UsrprofVw tms0008UsrprofVw) {

		String METHOD_NAME = "findUsr";

		Collection resultCol = null;
		PersistenceManager pm = null;

		try {
			pm = PersistenceUtil.getPersistenceManager();
			Query query = pm.newQuery("findUsrQuery", Tms0008UsrprofVw.class);
			query.setParameters(tms0008UsrprofVw);
			resultCol = (Collection) pm.executeQuery(query);
		} catch (PersistenceException e) {
			log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME,
					"ERROR buscando usuario.", e);
		}
		return resultCol;
	}
}
